import pygame, sys, math

from Block import Block

class MoveBlockSideways(Block): 
    def __init__(self, image, pos = (0,0), blocksize = [30,30]):
        Block.__init__(self, image, pos, blocksize)
    
    def place(self, pos):
        self.rect.center = pos
        
    def update(self,size):
        self.collideWall(size)
        self.move()

    def move(self):
        self.x += self.speedx
        self.y += self.speedy
        self.rect.center = (round(self.x), round(self.y))
    
    def direction(self, dir):
        if dir == "right":
            self.headingx = "right"
            self.speedx = self.maxSpeed
        if dir == "stop right":
            self.headingx = "right"
            self.speedx = 0
        if dir == "left":
            self.headingx = "left"
            self.speedx = -self.maxSpeed
        if dir == "stop left":
            self.headingx = "left"
            self.speedx = 0